package com.hylanda.sys.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.mobile.device.Device;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hylanda.pb.model.ReportModel;

/** 
 * @author zhangy
 * @E-mail:blackoon88@gmail.com 
 * @qq:846579287
 * @version created at：2018年1月24日 下午3:59:20 
 * note
 */
@Controller
public class WelcomeController {
	@RequestMapping(value={"/welcome","/"})
	public String welcome(HttpServletRequest request,
			HttpServletResponse response,ReportModel model){
		return "welcome";
	}
	/**
	 * 设备检测
	 * @param device
	 * @return
	 */
	@RequestMapping(value="/detect-device")
    public @ResponseBody String detectDevice(HttpServletRequest request,
			HttpServletResponse response,Device device){
        String deviceType="unknown";
        if(device.isNormal())
            deviceType = "normal";//Pc端
        else if (device.isMobile())
            deviceType = "mobile";//手机端
        else if (device.isTablet())
            deviceType = "tablet";//平板

        return "Hello " + deviceType + " browser!";
    }
}
